home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 20
/
Cream of the Crop 20 (Terry Blount) (1996).iso
/
program
/
vol15n11.zip
/
HKD.ZIP
/
HKDSRC.ZIP
/
HKDDLG.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1996-04-01
|
42KB
|
1,257 lines
// HKDdlg.cpp : implementation file
// HotKey Detective version 1.0
// Copyright (c) 1996 Ziff-Davis Publishing
// First published in PC Magazine June 11, 1996
// Author: Gregory A. Wolking
#include "stdafx.h"
#include "HKD.h"
#include "HKDdlg.h"
#include "HKDpDlg.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// Implementation
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//{{AFX_MSG(CAboutDlg)
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg message handlers
BOOL CAboutDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// If main window is minimized, center the about box on the screen,
// otherwise center it over the main window. All other code for the
// CAboutDlg class was generated by the App Wizard.
CenterWindow(GetOwner()->IsIconic() ? GetDesktopWindow() : NULL);
return TRUE; // return TRUE unless you set the focus to a control
}
/////////////////////////////////////////////////////////////////////////////
// CHKDDlg dialog
CHKDDlg::CHKDDlg(CWnd* pParent /*=NULL*/)
: CDialog(CHKDDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CHKDDlg)
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CHKDDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CHKDDlg)
DDX_Control(pDX, cmdPrint, m_cmdPrint);
DDX_Control(pDX, lblShortcut, m_lblShortcut);
DDX_Control(pDX, lblFilename, m_lblFilename);
DDX_Control(pDX, lblWarning, m_lblWarning);
DDX_Control(pDX, cmdRefresh, m_cmdRefresh);
DDX_Control(pDX, chkAutoScan, m_chkAutoScan);
DDX_Control(pDX, cmdExplore, m_cmdExplore);
DDX_Control(pDX, lstKeys, m_lstKeys);
DDX_Control(pDX, lstFiles, m_lstFiles);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CHKDDlg, CDialog)
//{{AFX_MSG_MAP(CHKDDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_SYSCOMMAND()
ON_BN_CLICKED(cmdRefresh, OncmdRefresh)
ON_LBN_SELCHANGE(lstKeys, OnSelchangelstKeys)
ON_LBN_DBLCLK(lstKeys, OnDblclklstKeys)
ON_BN_CLICKED(cmdExplore, OncmdExplore)
ON_BN_CLICKED(chkAutoScan, OnchkAutoScan)
ON_WM_SIZE()
ON_WM_GETMINMAXINFO()
ON_WM_CLOSE()
ON_BN_CLICKED(cmdPrint, OncmdPrint)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CHKDDlg message handlers
BOOL CHKDDlg::OnInitDialog()
{
RECT r;
// Wizard-Generated code.
CDialog::OnInitDialog();
CenterWindow();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
// Custom code
// Load our small and large icons.
SendMessage(WM_SETICON,(WPARAM)(BOOL)TRUE,(LPARAM)m_hIcon);
SendMessage(WM_SETICON,(WPARAM)(BOOL)FALSE,(LPARAM)m_hIcon);
// Set minimum tracking size for use by OnGetMinMaxInfo()
GetWindowRect(&r);
min_track_x = r.right - r.left;
min_track_y = r.bottom - r.top;
// Unless we're starting minimized, adjust control positions relative
// to the dialog borders.
if (!IsIconic())
Adjust_Controls();
// Initialize pointer for our worker thread.
my_thread = NULL;
// Get paths to the Start Menu and Desktop Folders.
if (!Get_Folder_Paths())
{
// If call fails, report error and quit.
Do_Error_Message("Could not read Explorer's folder\nsettings from the Registry.");
EndDialog(IDOK);
}
else
{
// Create dlg_Scanning screen window (initially hidden).
dlg_Scanning.Create(IDD_SPLASH, this);
// Read option settings from the Registry.
if (!Read_My_Settings())
{
// If read fails, set default and save it.
m_chkAutoScan.SetCheck(1);
Save_My_Settings();
}
// If Automatic Refresh is enabled,
if (m_chkAutoScan.GetCheck())
// start our worker thread, which automatically triggers a refresh.
Launch_Worker();
else
// Otherwise, refresh manually.
OncmdRefresh();
}
return TRUE; // return TRUE unless you set the focus to a control
}
// WM_GETMINMAXINFO handler
// Sets minimum dimensions when window is resized.
void CHKDDlg::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
{
// If dialog doesn't exist yet, controls won't exist either.
// We don't want to set this metric until the dialog has been
// created and OnInitDialog() has set the desired size.
if (m_lblShortcut)
{
lpMMI->ptMinTrackSize.x = min_track_x;
lpMMI->ptMinTrackSize.y = min_track_y;
}
}
// System menu handler (more Wizard code)
void CHKDDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
CDialog::OnSysCommand(nID, lParam);
}
// OnCancel is always called last when user exits. Since the user can exit this
// dialog by either clicking the close box or pressing {Esc}, we want to make sure
// that the necessary shutdown work is done regardless of the method used.
// Since there is no special processing required when the Close box is used,
// the CDialog::OnClose() member function is not overriden in this implementation.
void CHKDDlg::OnCancel()
{
// Make sure worker thread is shut down.
Kill_Worker();
// Save auto-refresh setting.
Save_My_Settings();
// Destroy the splash screen.
dlg_Scanning.DestroyWindow();
// Call base class to finish up and end the application.
CDialog::OnCancel();
}
// Handles drawing the icon if window is minimized.
// This function and OnQueryDragIcon() are both App Wizard code.
void CHKDDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
CDialog::OnPaint();
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CHKDDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
// The remainder of this file is custom code.
/////////////////////////////////
// Rearrange controls when dialog is resized
/////////////////////////////////
void CHKDDlg::OnSize(UINT nType, int cx, int cy)
{
// If the controls exist (On_Size is called once before the controls are drawn),
if (m_lblShortcut)
// and we're not being minimized,
if (nType != SIZE_MINIMIZED)
// adjust their positions.
Adjust_Controls();
}
/////////////////////////////
// Command button handlers //
/////////////////////////////
///////////////////////////
// Refresh Key List button.
// Also called by OnInitDialog() and our worker thread.
///////////////////////////
void CHKDDlg::OncmdRefresh()
{
// Disable button so the user can't stack up refresh requests.
m_cmdRefresh.EnableWindow(FALSE);
// If we'r